<template>
  <div>
    <FormPanel ref="form" :list="formList" :labelPosition="'top'" :labelWidth="130" :cols="3" :isSubmitBtn="false" :collapse="false" />
    <FormPanel ref="form" :list="formList2" :labelPosition="'top'" :labelWidth="130" :cols="3" :isSubmitBtn="false" :collapse="false" />

    <div v-if="type === 'detail'">

    </div>
    <div style="height: 47px"></div>

    <!-- <div class="footer"> -->
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        // textAlign: 'center',
        textAlign: 'right',
      }"
    >
      <el-button v-if="type !== 'detail' && rowData.isBind === 10041002 && rowData.status === 21461003" type="primary" :disabled="isShowBindSapCustomerNo" @click="bindSapCustomerNo()"
      >绑定SAP客户编号</el-button
      >
      <el-button v-if="type !== 'detail'" type="primary" :disabled="ischange" @click="closeDrawer(1)">通过</el-button>
      <el-button v-if="type !== 'detail'" type="primary" :disabled="ischange" @click="closeDrawer(2)">驳回</el-button>
      <el-button @click="closeDialog()">关 闭</el-button>
    </div>
    <BaseDialog
      :visible.sync="examineVue"
      :title="'审核意见'"
      width="850px"
      destroyOnClose
      :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }"
    >
      <examine @close="closeAdd" @save="saveAdd" :rowData="this.rowData" :types="this.types"></examine>
    </BaseDialog>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import config from '@/assets/js/config';
import { IDNumber, phoneAndSolidify, phone, zipCode } from '@/utils/validate';

import examine from './examine.vue';
import addDetail from './addDetail.vue';
import moment from 'moment';
export default {
  props: {
    type: {
      type: String,
      require: true,
    },
    rowData: {
      type: Object,
    },
  },
  components: { addDetail ,examine},
  data() {
    return {
      formList: this.createdFrom(),
      formList2: this.createdFrom2(),

      tableList: [],
      examineVue:false,
      // columnsUp: this.createdTableUp(),
      tableListUp: [],
      ischange: false,
      isShowBindSapCustomerNo: true,
      isAddDetail: false,
      addDetailType: 'demand',
      addRormData: {},
      datailData: {},
      current: null,
      demandSeries: [],
      demandModel: [],
      types:"",
    };
  },
  created() {

    //查詢查看頁面數據的值
    this.getListRecord();
    // 查看明细时，禁用
    if (this.type === 'detail') {
      this.formList.forEach((x) => {
        if (x.type !== 'BREAK_SPACE') {
          x.disabled = true;
        }
      });
    }
  },
  mounted() {
    //遍历主页面带过来的数据,循环放入页面   申请信息
    this.formList.forEach(x => {
      x.initialValue = this.rowData[x.fieldName];
    });

    //   大订单信息
    this.formList2.forEach(x => {
      x.initialValue = this.rowData[x.fieldName];
    });



    //初始化页面
    if (this.rowData.id) {
      this.init();
    }
  },
  mixins: [dictionary],
  methods: {

    closeAdd() {
      this.examineVue = false;
    },
    saveAdd() {
      this.examineVue = false;
      this.$emit('close')
      // this.fetchParams = { ...this.fetchParams };
    },

    closeDialog(type){
      this.$emit('close', { visible: false ,type:type});
    },

    //保存， 提交, 关闭
    async closeDrawer(type) {
      this.types = type;
      this.examineVue = true;
    },





    createdFrom() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '申请信息',
        },
        {
          type: 'INPUT',
          label: '申请经销商',
          fieldName: 'dealerName',//DEALER_NAME
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '归属区域',
          fieldName: 'regional',//REGIONAL
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '区域经理',
          fieldName: 'regionalManager',//REGIONAL_MANAGER
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '申请人',
          fieldName: 'applyPersonName',//APPLY_PERSON_NAME
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '联系方式',
          fieldName: 'applyMobile',//APPLY_MOBILE
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '申请时间',
          fieldName: 'applyRefundTime',//APPLY_REFUND_TIME
          disabled: true,
        },

        {
          type: 'INPUT',
          label: '申请理由',
          fieldName: 'applyReason',//APPLY_REASON
          disabled: true,
        },

      ];
    },

    createdFrom2() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '大定订单信息',
        },
        {
          type: 'INPUT',
          label: '客户名称',
          fieldName: 'customerName',//CUSTOMER_NAME
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '客户手机号',
          fieldName: 'customerMobile',//CUSTOMER_MOBILE
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '预订单号',
          fieldName: 'wishApplyNo',//WISH_APPLY_NO
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '大定金额',
          fieldName: 'largeFixedAmount',//LARGE_FIXED_AMOUNT
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '支付时间',
          fieldName: 'paymentTime',//PAYMENT_TIME
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '车系',
          fieldName: 'seriesName',//SERIES_NAME
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '车型',
          fieldName: 'modelName',//MODEL_NAME
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '配置',
          fieldName: 'packageName',//PACKAGE_NAME
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '选装',
          fieldName: 'optionName',//OPTION_NAME
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '内饰',
          fieldName: 'trimName',//TRIM_NAME
          disabled: true,
        },
        {
          type: 'INPUT',
          label: '外观',
          fieldName: 'guiseName',//GUISE_NAME
          disabled: true,
        },

      ];
    },

  },
};
</script>
<style lang="scss">
.footer {
  position: 'absolute';
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 9;
  border-top: '1px solid #e9e9e9';
  padding: '10px 20px';
  background: '#fff';
  text-align: 'right';
  padding: 20px 30%;
  box-sizing: border-box;
  display: flex;
  justify-content: space-around;
}
.upload-btn {
  width: 100%;
}
.el-upload-list__item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  padding-right: 20px;
  box-sizing: border-box;
}
</style>
